package javabase.collection.list.thread;

import java.util.Enumeration;
import java.util.List;
import java.util.Vector;

class VectorRunnable implements Runnable {
	
	private Vector<String> vector = null;
	
	public VectorRunnable(Vector<String> vector) {
		super();
		this.vector = vector;
	}

	public Vector<String> getVector() {
		return vector;
	}

	public void setVector(Vector<String> vector) {
		this.vector = vector;
	}
	int i = 0;
	public void run() {
		for (; i < 6; i++) {
//			try {
//				Thread.sleep(1);
//			}
//			catch(InterruptedException e) {
//				e.printStackTrace();
//			}
			vector.add(i + "");
		}
	}
	
}

public class VectorSecurity {

	public static void main(String[] args) {
		List<String> vector = new Vector<String>();
		Vector<String> v = (Vector<String>)vector;
		VectorRunnable myRunable0 = new VectorRunnable(v);
		VectorRunnable myRunable1 = new VectorRunnable(v);
		Thread myThread0 = new Thread(myRunable0);
		Thread myThread1 = new Thread(myRunable1);
		myThread0.start();
		myThread1.start();
		try {
			Thread.sleep(3000);
		} catch (InterruptedException e1) {
			e1.printStackTrace();
		}
		Enumeration<String> e = v.elements();
		while (e.hasMoreElements()) {
			System.out.print(e.nextElement());
		}
		System.out.println("\n------无比华丽的分割线------");
	}

}
